package controller

import (
	"github.com/gin-gonic/gin"
	dtoUser "mxshop/app/mxshop_api/admin/internal/domain/dto/user"
	"mxshop/gmicro/pkg/common/core"
	v1 "mxshop/gmicro/pkg/common/meta/v1"
	translatorGin "mxshop/pkg/translator/gin"
	"net/http"
)

func (us *userServer) List(ctx *gin.Context) {
	var r dtoUser.UserFilter

	if err := ctx.ShouldBindQuery(&r); err != nil {
		translatorGin.HandleValidatorError(ctx, err, us.trans)
	}

	res, err := us.srv.User().List(ctx, []string{}, v1.ListMeta{int(r.Pages), int(r.PagePerNums)})
	if err != nil {
		core.WriteResponse(ctx, err, nil)
		return
	}
	ctx.JSON(http.StatusOK, res)
	return
}
